#include "../tools.h"


class Solution {
public:
    int rob(vector<int>& nums) {
        int size = nums.size();
        if(size == 0) return 0;
        if(size == 1) return nums[0];
        
        int dp[size] = {0};
        dp[0] = nums[0];
        dp[1] = max(nums[0], nums[1]);

        for(int i = 2; i < size; ++i){
            dp[i] = max(nums[i] + dp[i - 2], dp[i - 1]);
        }

        return dp[size - 1];
    }
};

int main(int argc, char const *argv[])
{
    Solution sol;

    vector<int> nums = {2,7,9,3,1};

    int res = sol.rob(nums);
    cout << res << endl;

    return 0;
}
